package Offer;

public class T10_2numWays {

    //  递归法
    int[] memo = new int[101]; //记忆型递归
    public int numWays(int n) {
        if (n == 0 || n == 1) {
            return 1;
        }
        if (memo[n] == 0) {
            int ans = (numWays(n - 1) + numWays(n - 2)) % 1000000007;
            memo[n] = ans;
            return ans;
        }
        return memo[n];
    }

    //    动态规划
    public int numWays_1(int n) {
        if (n == 0 || n == 1) {
            return 1;
        }
        int[] dp = new int[n+1];
        dp[0] = dp[1] = 1;
        for (int i = 2; i <= n; i++) {
            dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
        }

        return dp[n];
    }
}